package com.sugon.controller;

import cn.hutool.core.collection.CollectionUtil;
import com.sugon.dao.SysDictDao;
import com.sugon.entity.SysDictItem;
import com.sugon.utils.R;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统数据字典Controller
 *
 * @author lipengjun
 * @date 2017-12-25 18:26:15
 */
@Controller
@RequestMapping("/sys/dict")
public class SysDictController {

    @Resource
    private SysDictDao dictDao;

    /**
     * 查看列表
     */
    @RequestMapping("/listDictItemByCode")
    @ResponseBody
    public R listDictItemByCode(@RequestParam String dictCode) {
        List<SysDictItem> dictItems = dictDao.listByDictCode(dictCode);
        if (dictItems == null) {
            dictItems = CollectionUtil.newArrayList();
        }
        return R.ok().put("list", dictItems);
    }

}
